package com.yun.zf.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yun.zf.admin.mapper.ZfCommunityBusinessMapper;
import com.yun.zf.admin.service.ZfCommunityBusinessService;
import com.yun.zf.common.admin.domain.ZfCommunityBusiness;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 社区商圈表 服务实现类
 * </p>
 *
 * @author cj
 * @since 2021-05-17
 */
@Service
public class ZfCommunityBusinessServiceImpl extends ServiceImpl<ZfCommunityBusinessMapper, ZfCommunityBusiness> implements ZfCommunityBusinessService {

    @Override
    public Boolean addBusiness(List<ZfCommunityBusiness> businessLists) {
        return this.saveBatch(businessLists);
    }

    @Override
    public List<String> getBusiness(Long communityId) {
        QueryWrapper<ZfCommunityBusiness> businessQueryWrapper = new QueryWrapper<>();
        businessQueryWrapper.lambda().eq(ZfCommunityBusiness::getCommunityId,communityId);
        List<ZfCommunityBusiness> businessList = baseMapper.selectList(businessQueryWrapper);
        if (businessList.size()>0){
            return    businessList.stream().map(b->b.getBusinessName()).collect(Collectors.toList());
        }
     return  null;
    }
}
